Skip to content

fix(pad): show revision authors in the history banner - #8594

Open
TomNewChao wants to merge 2 commits into
ether:masterfrom
TomNewChao:fix/8593-history-banner-authors
Open

TomNewChao wants to merge 2 commits into
ether:masterfrom
TomNewChao:fix/8593-history-banner-authors

Conversation

@TomNewChao

Copy link
Copy Markdown

Fixes #8593

Summary

  • In-pad history mode showed no authors anywhere visible: the embedded timeslider's authors line collapses with its bar in embed mode, and the existing mirror lands in the closed users popup (anatomy + local repro in History mode: authors of the viewed revision are only visible in the closed users popup #8593).
  • Fix: mirror the embedded slider's localized authors label + names into a new #history-banner-authors span on every revision change, and clear it on exit. No new l10n keys — the label text comes from the inner timeslider's own localized .authors-label.
  • syncAuthorsPanel now also re-runs on inner #authorsList / .authors-label DOM mutations (MutationObserver, same pattern as the rev/date label bridge), so the banner stays current without a scrub; an equality guard keeps the aria-live=polite banner from re-announcing identical text during playback.
  • Discovered while testing (out of scope here, flagged for follow-up): the server never emits NEW_AUTHORDATA, so the embedded slider's authorData is a load-time snapshot — authors who join/name themselves after load resolve to undefined in setAuthors and are skipped. Same on the classic timeslider page; candidate upstream fix is to include revision-author data in NEW_CHANGES or revive the emission on USERINFO_UPDATE.

Banner now reads: Viewing history | Version N | Saved <date> | Authors: <names>.

Test plan

  • New Playwright spec timeslider_banner_authors.spec.ts:
    • named author → enter history mode → scrub to the write revision → banner contains the author name (watched it fail before the fix — RED, passes after — GREEN)
    • banner follows async inner #authorsList mutations without a slider callback (contract test; RED without the MutationObserver)
    • banner authors clear on exiting history mode
  • Neighboring timeslider specs pass unchanged: revision_labels, saved_revisions ×2, deeplink ×2, follow ×2, author_colors — 11 passed
  • pnpm run ts-check clean

🤖 Generated with Claude Code

Since in-pad history mode (ether#7659, implemented in ether#7710), the authors of
the viewed revision are effectively invisible: the embedded slider bar
collapses in embed mode, the #otheruserstable mirror lives in the closed
users popup, and the banner showed only the version and date. This
regressed from the classic timeslider page, which displayed an
"Authors: ..." line under the slider.

Mirror the embedded timeslider's localized authors label and list into a
new #history-banner-authors span. syncAuthorsPanel now also runs on
inner #authorsList / .authors-label mutations (MutationObserver, same
pattern as the rev/date label bridge) so the banner stays current without
a scrub; an equality guard keeps the banner's aria-live=polite region
from re-announcing identical text during playback.

Fixes ether#8593

Co-Authored-By: Claude Code <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

fix(pad): show revision authors in the history banner

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• In history mode, the viewed revision's authors are now mirrored into the history banner.
• The banner updates on every revision change and on async inner authors-list mutations, and clears
 on exit.
• A new Playwright spec covers the banner authors: display, async updates, and clearing on exit.
Merge Risk 🟢 Low

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The template creates the banner carrier, pad_mode synchronizes the embedded timeslider's revision-specific author content into it, and CSS controls its presentation.
  • These are implementation hops for one user-visible history-viewing behavior, not independent capabilities.
Sources

src/static/js/pad_mode.ts[344-357]

    const authorsObserver = new MutationObserver(() => { this.syncAuthorsPanel(win); });
    const innerAuthorsList = doc.getElementById('authorsList');
    if (innerAuthorsList) {
      authorsObserver.observe(
          innerAuthorsList, {childList: true, subtree: true, characterData: true});
    }
    const innerAuthorsLabel = doc.querySelector('.authors-label');
    if (innerAuthorsLabel) {
      authorsObserver.observe(
          innerAuthorsLabel, {childList: true, subtree: true, characterData: true});
    }
    // Unlike revObserver, this observer is per-mount: keep it in a field so
    // unmountIframe can disconnect it when the iframe is torn down.
    this.authorsObserver = authorsObserver;

src/static/js/pad_mode.ts[595-606]

    const innerLabel = (innerWin.document as Document).querySelector<HTMLElement>('.authors-label');
    const label = innerLabel?.textContent || '';
    const bannerText = (label ? `${label} ` : '') + text;
    // Equality guard: syncAuthorsPanel runs on every slider step AND on every
    // inner #authorsList mutation; skip redundant writes so the banner's
    // aria-live=polite region doesn't re-announce identical text during
    // playback or unrelated DOM churn.
    if (this.bannerAuthors.textContent !== bannerText) {
      this.bannerAuthors.textContent = bannerText;
    }
    const tbl = document.getElementById('otheruserstable');
    if (!tbl || tbl.textContent === text) return;

src/templates/pad.html[218-218]

    <span class="history-banner-authors" id="history-banner-authors"></span>

src/static/css/pad.css[149-154]

/* Narrow screens: the banner's other segments fill the first row; give the
 * authors their own full-width row so they are not squeezed to a sliver. */
@media (max-width: 600px) {
  .history-banner-authors {
    flex: 1 1 100%;
  }

src/static/js/broadcast.ts[496-514]

        if (obj.type === 'NEW_CHANGES') {
          const changeset = moveOpsToNewPool(
              obj.changeset, (new AttribPool()).fromJsonable(obj.apool), padContents.apool);

          let changesetBack = inverse(
              obj.changeset, padContents.currentLines, padContents.alines, padContents.apool);

          changesetBack = moveOpsToNewPool(
              changesetBack, (new AttribPool()).fromJsonable(obj.apool), padContents.apool);

          loadedNewChangeset(changeset, changesetBack, obj.newRev - 1, obj.timeDelta);
        } else if (obj.type === 'NEW_AUTHORDATA') {
          const authorMap = {};
          authorMap[obj.author] = obj.data;
          receiveAuthorData(authorMap);

          const authors = _.map(padContents.getActiveAuthors(), (name) => authorData[name]);

          BroadcastSlider.setAuthors(authors);
Behavioral complexity 🟡 Medium 🧩 Interacting branches

  • Before: authors were mirrored during revision changes into the history users panel.
  • After: the same content is also synchronized into a banner through a per-iframe MutationObserver, with observer teardown, label/list mutation handling, equality suppression, and responsive layout states.
  • New correctness condition: updates must reach the banner while mounted without stale writes after unmount, while preserving the live users panel restoration path.
  • The existing author rendering and revision machinery remains unchanged; the interaction is the new asynchronous observer lifecycle and dual presentation synchronization.
Sources

src/static/js/pad_mode.ts[344-357]

    const authorsObserver = new MutationObserver(() => { this.syncAuthorsPanel(win); });
    const innerAuthorsList = doc.getElementById('authorsList');
    if (innerAuthorsList) {
      authorsObserver.observe(
          innerAuthorsList, {childList: true, subtree: true, characterData: true});
    }
    const innerAuthorsLabel = doc.querySelector('.authors-label');
    if (innerAuthorsLabel) {
      authorsObserver.observe(
          innerAuthorsLabel, {childList: true, subtree: true, characterData: true});
    }
    // Unlike revObserver, this observer is per-mount: keep it in a field so
    // unmountIframe can disconnect it when the iframe is torn down.
    this.authorsObserver = authorsObserver;

src/static/js/pad_mode.ts[595-606]

    const innerLabel = (innerWin.document as Document).querySelector<HTMLElement>('.authors-label');
    const label = innerLabel?.textContent || '';
    const bannerText = (label ? `${label} ` : '') + text;
    // Equality guard: syncAuthorsPanel runs on every slider step AND on every
    // inner #authorsList mutation; skip redundant writes so the banner's
    // aria-live=polite region doesn't re-announce identical text during
    // playback or unrelated DOM churn.
    if (this.bannerAuthors.textContent !== bannerText) {
      this.bannerAuthors.textContent = bannerText;
    }
    const tbl = document.getElementById('otheruserstable');
    if (!tbl || tbl.textContent === text) return;

src/static/css/pad.css[149-154]

/* Narrow screens: the banner's other segments fill the first row; give the
 * authors their own full-width row so they are not squeezed to a sliver. */
@media (max-width: 600px) {
  .history-banner-authors {
    flex: 1 1 100%;
  }

src/static/js/broadcast.ts[496-514]

        if (obj.type === 'NEW_CHANGES') {
          const changeset = moveOpsToNewPool(
              obj.changeset, (new AttribPool()).fromJsonable(obj.apool), padContents.apool);

          let changesetBack = inverse(
              obj.changeset, padContents.currentLines, padContents.alines, padContents.apool);

          changesetBack = moveOpsToNewPool(
              changesetBack, (new AttribPool()).fromJsonable(obj.apool), padContents.apool);

          loadedNewChangeset(changeset, changesetBack, obj.newRev - 1, obj.timeDelta);
        } else if (obj.type === 'NEW_AUTHORDATA') {
          const authorMap = {};
          authorMap[obj.author] = obj.data;
          receiveAuthorData(authorMap);

          const authors = _.map(padContents.getActiveAuthors(), (name) => authorData[name]);

          BroadcastSlider.setAuthors(authors);
Potential damage 🟢 Low 🩹 Cosmetic

  • If the changed synchronization or layout regresses, users may not see which authors contributed to the selected historical revision or may have reduced readability on narrow screens.
  • The affected outcome is informational presentation; no pad data or external effect is changed.
  • Reverting the frontend changes restores the previous history-view presentation.
  • No persistent state repair, replay, or external compensation is required.
Sources

src/static/js/pad_mode.ts[344-357]

    const authorsObserver = new MutationObserver(() => { this.syncAuthorsPanel(win); });
    const innerAuthorsList = doc.getElementById('authorsList');
    if (innerAuthorsList) {
      authorsObserver.observe(
          innerAuthorsList, {childList: true, subtree: true, characterData: true});
    }
    const innerAuthorsLabel = doc.querySelector('.authors-label');
    if (innerAuthorsLabel) {
      authorsObserver.observe(
          innerAuthorsLabel, {childList: true, subtree: true, characterData: true});
    }
    // Unlike revObserver, this observer is per-mount: keep it in a field so
    // unmountIframe can disconnect it when the iframe is torn down.
    this.authorsObserver = authorsObserver;

src/static/js/pad_mode.ts[595-606]

    const innerLabel = (innerWin.document as Document).querySelector<HTMLElement>('.authors-label');
    const label = innerLabel?.textContent || '';
    const bannerText = (label ? `${label} ` : '') + text;
    // Equality guard: syncAuthorsPanel runs on every slider step AND on every
    // inner #authorsList mutation; skip redundant writes so the banner's
    // aria-live=polite region doesn't re-announce identical text during
    // playback or unrelated DOM churn.
    if (this.bannerAuthors.textContent !== bannerText) {
      this.bannerAuthors.textContent = bannerText;
    }
    const tbl = document.getElementById('otheruserstable');
    if (!tbl || tbl.textContent === text) return;

src/templates/pad.html[218-218]

    <span class="history-banner-authors" id="history-banner-authors"></span>

src/static/css/pad.css[149-154]

/* Narrow screens: the banner's other segments fill the first row; give the
 * authors their own full-width row so they are not squeezed to a sliver. */
@media (max-width: 600px) {
  .history-banner-authors {
    flex: 1 1 100%;
  }

src/static/js/broadcast.ts[496-514]

        if (obj.type === 'NEW_CHANGES') {
          const changeset = moveOpsToNewPool(
              obj.changeset, (new AttribPool()).fromJsonable(obj.apool), padContents.apool);

          let changesetBack = inverse(
              obj.changeset, padContents.currentLines, padContents.alines, padContents.apool);

          changesetBack = moveOpsToNewPool(
              changesetBack, (new AttribPool()).fromJsonable(obj.apool), padContents.apool);

          loadedNewChangeset(changeset, changesetBack, obj.newRev - 1, obj.timeDelta);
        } else if (obj.type === 'NEW_AUTHORDATA') {
          const authorMap = {};
          authorMap[obj.author] = obj.data;
          receiveAuthorData(authorMap);

          const authors = _.map(padContents.getActiveAuthors(), (name) => authorData[name]);

          BroadcastSlider.setAuthors(authors);
Assessed commit d631aeb
Diagram

graph TD
  A["Inner #authorsList"] --> B["MutationObserver"] --> C["syncAuthorsPanel"] --> D["#history-banner-authors"]
  E["Slider step callback"] --> C
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Force the embedded slider's authors line visible via CSS
  • ➕ No JS mirroring or observer needed
  • ➕ Keeps the authors next to the slider where they originally appeared
  • ➖ The bar is collapsed in embed mode, so the line would need layout changes
  • ➖ Depends on the inner timeslider DOM and CSS staying stable
2. Fix the server to emit NEW_AUTHORDATA or include author data in NEW_CHANGES
  • ➕ Addresses the root cause of stale author data, not only the display
  • ➕ Benefits the classic timeslider page too
  • ➖ Server protocol change with wider blast radius
  • ➖ Does not by itself make the banner visible in embed mode

Recommendation: Keep the banner mirror with a MutationObserver. It is the only always-visible carrier in embed mode, and the observer covers async author updates without a scrub. The root cause, a load-time authorData snapshot because NEW_AUTHORDATA is never emitted, is correctly deferred to a follow-up.

Files changed (4) +144 / -4

Enhancement (2) +8 / -0
pad.cssStyle the new banner authors span +7/-0

Style the new banner authors span

• Adds a .history-banner-authors rule with reduced opacity and single-line ellipsis overflow. This keeps long author lists from breaking the banner layout.

src/static/css/pad.css

pad.htmlAdd authors span to history banner markup +1/-0

Add authors span to history banner markup

• Inserts an empty span with id history-banner-authors between the date and the return button. It is the target that pad_mode.ts populates.

src/templates/pad.html

Bug fix (1) +45 / -4
pad_mode.tsMirror revision authors into history banner +45/-4

Mirror revision authors into history banner

• Adds a bannerAuthors field and writes the inner label plus names to it in syncAuthorsPanel, guarded by an equality check. A per-mount MutationObserver on the inner #authorsList and .authors-label re-runs the sync, and the banner is cleared on exit and the observer is disconnected on unmount.

src/static/js/pad_mode.ts

Tests (1) +91 / -0
timeslider_banner_authors.spec.tsAdd Playwright spec for banner authors +91/-0

Add Playwright spec for banner authors

• Adds three serial tests. They check that the banner shows the author of the viewed revision, that it follows async inner authorsList mutations without a scrub, and that it clears on exit from history mode.

src/tests/frontend-new/specs/timeslider_banner_authors.spec.ts

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Mobile readers cannot see history authors ✓ Resolved Bug Correctness

Resolving commit: d631aeb

Resolution reason
Added flex-wrap on .history-banner and a max-width:600px rule giving .history-banner-authors flex: 1
1 100% so authors wrap onto their own full-width row on narrow screens; added a mobile-width
Playwright test asserting no horizontal overflow and authors width >= 150px.
Description
The new .history-banner-authors rule allows the authors span to shrink to zero width and clips its
contents. On narrow mobile screens, the banner’s label, revision, date, return button, padding, and
gaps consume the available row width, leaving the author names invisible even though they are
populated.

Grey Divider

Tip of the day
💡 Did you know, you can pick a display mode instead of tweaking every Display option by hand

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

At narrow widths the banner's single flex row squeezed the authors span
to a sliver (55px at 390px viewport — just the ellipsized "Authors:"
label) and wrapped the date internally across three lines. Let the
banner wrap, keep the label/rev/date segments on one line, and give the
authors their own full-width row below 600px. The new mobile spec
asserts the page does not scroll horizontally and the authors span keeps
a readable width.

Co-Authored-By: Claude Code <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant